use strict;
use utf8;

my @a = ("им", "мин", "тыс", "англ", "нем", "фр", "рус", "(англ", "(нем");
my %abbr = map {$_ => 1} @a;

binmode(STDIN, ":encoding(utf-8)");
binmode(STDOUT, ":encoding(utf-8)");

$/ = "</sentence>";

while (<STDIN>) {
  if ($_ =~ /<sentence id=\"(\d+)\">\s+<source>([^<]+)<\/source>/ms) {
    my ($id, $text) = ($1, $2);
    if ($text =~ /\s([^А-ЯЁA-Z0-9]+)[\.\!\?]\s+[А-ЯЁA-Z]/) {
      if (exists $abbr{$1}) { next; }
      print "$id\t$text\n";
    }
  }
}
